package com.yisoo.ubag.app.service.impl;

import com.yisoo.common.utils.R;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yisoo.common.utils.PageUtils;
import com.yisoo.common.utils.Query;

import com.yisoo.ubag.app.dao.CouponDao;
import com.yisoo.ubag.app.entity.CouponEntity;
import com.yisoo.ubag.app.service.CouponService;


@Service("couponService")
public class CouponServiceImpl extends ServiceImpl<CouponDao, CouponEntity> implements CouponService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<CouponEntity> page = this.page(
                new Query<CouponEntity>().getPage(params),
                new QueryWrapper<CouponEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public R getAllWithNewUser(String uid) {

        return null;
    }

    @Override
    public List<CouponEntity> getCouponByIds(Integer[] ids) {
        List<CouponEntity> list = new ArrayList<>();
        for (Integer item:
                ids) {
            CouponEntity couponEntity = baseMapper.selectById(item);
            if(couponEntity != null){
                list.add(couponEntity);
            }
        }
        return list;
    }

}